<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/comm/mytags.jsp" %>
<!DOCTYPE>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta name="format-detection" content="telephone=no"/>
    <link rel="stylesheet" href="${ctx}/static/wxcss/apple.css">
    <link rel="stylesheet" href="${ctx}/static/wxcss/index.css">
    <script type="text/javascript" src="${ctx}/static/js/jquery-1.8.3.js"></script>
</head>
<body >
<div class="header gradient_bg">
    <div class="header_logo">
        <a onclick="window.history.back()" class="header_back"> &lt </a>
        <span>注册</span>
    </div>
</div>

<!--注册-->

<div class="login_div">
    <span class="login_ltext">手机号</span>
    <input class="login_input" type="tel" maxlength="11" placeholder="输入您的手机号码 用于兑奖" id="tel"/>
</div>
<%--<div class="login_div">--%>
    <%--<span class="login_ltext">验证码</span>--%>
    <%--<div class="auth_div">--%>
        <%--<input class="login_input auth_input" type="tel" maxlength="6" placeholder="输入验证码" />--%>
        <%--<div class="get_auth_code">--%>
            <%--<span>获取验证码</span>--%>
        <%--</div>--%>
    <%--</div>--%>
<%--</div>--%>
<div class="login_div">
    <span class="login_ltext">密码</span>
    <input class="login_input" type="password" maxlength="11" placeholder="设置您的登录密码" id="password"/>
</div>
<div class="login_div">
    <span class="login_ltext">确认密码</span>
    <input class="login_input" type="password" maxlength="11" placeholder="请确认密码" id="passwordConfirm"/>
</div>
<div class="register_action"  >
    <span >注册</span>
</div>
<div class="register_div">
    <a href="${ctx}/wxLogin" class="register_text"  >
        已有账号，请登录
    </a>
</div>

<script>
    $(function () {
        //获取所有的输入框
        var flag = true;//是否全部输入  默认true

        $(".login_input").keyup(function(){
            registerBtnShow();
        });

        function registerBtnShow() {
            $(".login_input").each(function () {
                if($(this).val()==""){
                    flag = true;
                    return false
                }else{
                    flag=false;
                }
            });
            if(flag){
                $(".register_action").removeClass("gradient_bg");
            }else{
                $(".register_action").addClass("gradient_bg");
            }
        }

        $(".register_action").click(
            function () {
                var tel = $("#tel").val();
                var password = $("#password").val().trim();
                var passwordConfirm = $("#passwordConfirm").val().trim();
                if(!(/^1[34578]\d{9}$/.test(tel))){
                    alert("请输入正确手机号");
                    return;
                }
                else if(password===null || password.length <6 || password.length > 20){
                    alert("密码必须6到20位之间");
                    return;
                }
                else if(password !== passwordConfirm){
                    alert("确认密码必须和密码相同");
                    return;
                }
                $.ajax({
                    url:"${ctx}/wxRegist.do",
                    dataType:"json",
                    type:"post",
                    data:{
                         tel:tel,
                        password:password
                    },
                    success:function(res){
                        if(res.code === 0){
                            alert("注册成功，去登陆");
                            window.location.href="${ctx}/wxLogin";
                        }
                        else{
                            alert(res.msg);
                        }
                    }
                });

            }
        );
//        // 验证码倒计时
//        var validCode=true;
//        $(".get_auth_code").click (function  () {
//            var time=30;
//            var $code=$(this);
//            $code.html(time+"秒");
//            if (validCode) {
//                validCode=false;
//                var codeTimer=setInterval(function  () {
//                    time--;
//                    $code.html(time+"秒");
//                    if (time==0) {
//                        clearInterval(codeTimer);
//                        $code.html("重新获取");
//                        validCode=true;
//                    }
//                },1000)
//            }
//        })


    })
</script>
</body>
</html>
